extends "../bailong-1/bailong-1.gd"


func _extInit():
	._extInit()
	if isInManual():
		addSkill(sk1t1[1], sk1t1[0])
		addSkill(sk1t2[1], sk1t2[0])
	elif sk1 != 0:
		doChoiceSkill1()
	lv = 2             #等级的设置

var sk1t1 = ["天雷罪灭·1", "每10秒审判罪孽最为深重之人(伤害最高的敌人)，对其造成[航空*5]的技能伤害并<放逐>2秒"]
var sk1t2 = ["天雷罪灭·2", "每10秒审判最为脆弱之人(血量最低的敌人)，对其造成[航空*5]的技能伤害"]

func doChoiceSkill1():
	if sk1 == 1:
		addSkill("每{cd}秒审判罪孽最为深重之人(伤害最高的敌人)，对其造成[航空*5]的技能伤害并<放逐>2秒", sk1t1[0], "bailong2", 10)
	if sk1 == 2:
		addSkill("每{cd}秒审判最为脆弱之人(血量最低的敌人)，对其造成[航空*5]的技能伤害", sk1t2[0], "bailong2", 10)

func _castCdSkill(id):
	._castCdSkill(id)
	if id=="bailong2":
		tianleizm()

var record = {}
func _onBattleEnd():
	._onBattleEnd()
	record.clear()

func getEnemyByDmg():
	var values = azurCtrl.statis2.values()
	values.sort_custom(self, "sortStatis")
	for i in values:
		if not i.cha.isDeath and i.cha.hasBuff("b_baolong") == null:
			return i.cha
	return null

func tianleizm(cha = null, flag = true):
	if cha == null:
		if sk1 == 1:
			cha = getEnemyByDmg()
		else:
			cha = getFirstCha(1, "sortByHp")
	if cha == null:return
	createCustEff(cha.position, "eff/thunder", 10, false, 2, Vector2(0, -20))
	var p = 1
	if not flag:p *= 0.5
	azurHurtChara(cha, att.air * 5 * p, sys.HurtType.REAL, sys.AtkType.SKILL, "天雷罪灭")
	utils.dicPlus(record, cha, 1)
	if not cha.isDeath and cha.hasBuff("b_fangZhu") == null and flag and cha.hasBuff("b_baolong") == null:
		var fz = 2
		if cha.type == sys.CharaClass.BOSS:fz = 1
		castBuff(cha, buff.b_fangZhu.new(fz))

	cha.addBuff(b_baolong.new(5))

class b_baolong:
	extends "../../../../azurlane_ctrl/AzurBuff.gd"
	func _init(lv = 1):
		attInit()
		id = "b_baolong"
		life = lv
		dispel = 2